﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.BodyClass = "easyui-layout";
}

<div id="tbtool" class="gou-toolbar" style="padding:3px;">
     <form method="post" action="/WorkTask/TaskSetIndex" id="searchForm">
    <span>任务集名称:</span>
    <input id="searchKey" name="searchKey" maxlength="25" style="line-height:26px;border:1px solid #ccc">
    <a href="javascript:;" class="easyui-linkbutton" iconcls="icon-search" onclick="Search();">查找</a>
    <a href="javascript:void(0);" onclick="addOrEditTaskSet(0);" class="easyui-linkbutton" iconcls="icon-add">新增</a>
        </form>
</div>

<table id="grid" data-options="region:'center',border:false" class="easyui-datagrid"
       rownumbers="true" fitcolumns="true" singleselect="true" fit="true" pagesize="50"></table>

@section Script{

    <script type="text/javascript">
        $(function () {
            function formatOper(val, row, index) {
                var rek = "";
                var cor = "";
                var opt = "";
                opt = opt + '&nbsp<a href="javascript:void(0);"onclick="viewTaskOperate(\'' + row.SetId +'\');">任务管理</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="addOrEditTaskSet(\'' + row.SetId + '\');">编辑</a>&nbsp|&nbsp;<a href="javascript:void(0);" onclick="deleteTaskSet(\'' + row.SetId + '\');">删除</a>&nbsp';

                return opt ;
            }
            $('#grid').datagrid({
                url: 'GetList?searchKey=' + $("#searchKey").val(),
                columns: [[
                     { field: 'SetId', title: 'Id', width: 70 }
                     ,{ field: 'SetName', title: '任务集名称', width: 250 }
                   
                    , { field: '_operate', title: '操作', width: 100, align: 'center', formatter: formatOper }
                ]],
                toolbar: '#tbtool',
                pagination: true
            });
            var pager = $('#grid').datagrid('getPager');	// get the pager of datagrid
            pager.pagination({
                showPageList: true,
                pageSize: 50
            });

        });
        function Search() {            
            $('#grid').datagrid("load", {
                searchKey: $("#searchKey").val()
            });
        }

        function deleteTaskSet(id) {
            var rek = "删除";
            $.messager.confirm(rek, "你确定" + rek + "”" + name + "“吗?", function (istrue) {
                if (istrue) {
                    var param = { setId: id };
                    $.ajax({
                        "type": "Post",
                        "url": "ajaxDeleteTaskSet?t=" + new Date().getTime(),
                        "dataType": "json",
                        "data": param,
                        "success": function (data) {
                          if (data.IsSuccess) {
                                $.messager.alert('提示', data.Msg);
                                $("#grid").datagrid("reload");
                            }
                            else
                            {
                                $.messager.alert('提示', data.Msg);
                             }
                        }
                    });
                }
            });
           
        }

           //查看订单详情
    function viewTaskOperate(id) {
        utils.TabAddIntoParent("tabContainer", "订单详情", '', '/WorkTask/taskIndex?taskSetId=' + id);
    }

        function addOrEditTaskSet(id) {
            window.location.href = "AddOrEditTaskSet?id=" + id;
        }


    </script>
}





